package com.example;

import com.example.model.User;
import com.example.service.UserService;

import java.util.Arrays;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        UserService userService = new UserService();

        // 添加初始数据
        userService.addUsers(Arrays.asList(
                new User(1, "Alice", 25),
                new User(2, "Bob", 30),
                new User(3, "Charlie", 35)
        ));

        // 1. 查询数据
        User user = userService.findUserById(2);
        System.out.println("查询结果: " + user);

        // 2. 修改数据
        userService.updateUser(new User(2, "Bob Updated", 31));
        System.out.println("修改后的用户列表:");
        userService.printAllUsers();

        // 3. 批量删除数据
        userService.deleteUsersByIds(new int[]{1, 3});
        System.out.println("删除后的用户列表:");
        userService.printAllUsers();

        // 4. 批量添加数据
        userService.addUsers(Arrays.asList(
                new User(4, "David", 40),
                new User(5, "Eve", 45)
        ));
        System.out.println("批量添加后的用户列表:");
        userService.printAllUsers();
    }
}